'use strict';

stareal
    .controller("HistoryBigSignController", function ($scope,$interval,$document, $stateParams, $api, $sce, base64, $state, $alert,localStorageService,$timeout,$lazyLoader) {
        // 加载对应演出种类的内容
        $scope.index=$stateParams.indexId;
        $scope.pageCount = 1;
        $scope.page_size = 30;
        $scope.indexweeks=['SUN','MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT' ];
        $scope.indexMonth=['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
        //$scope.goods = new $lazyLoader("app/view/history", {},true);
        $api.get("app/view/historylist", {
            pageNum: 1,
            pageSize: $scope.page_size
        },true).then(function (ret) {
            var data=ret.data;

            for(var i=0;i<data.length;i++){
                var d_Date = new Date(data[i].history_data);
                data[i].riliMonth=$scope.indexMonth[d_Date.getMonth()];
                data[i].riliWeek=$scope.indexweeks[d_Date.getDay()];
            }


            $scope.goods = data;
            // console.log($scope.goods);
            //暂无内容
        });

        $scope.completeadsRepeat=function(){
           //$("#loading0_img").css('display','none');
            setTimeout(function () {
                var  certifySwiper = new Swiper('#historySign .swiper-container', {
                    watchSlidesProgress: true,
                    slidesPerView: 'auto',
                    centeredSlides: true,
                   // loop: true,
                   //  loopedSlides: $scope.adsLength,
                    // autoplay: {
                    //     disableOnInteraction: false,
                    // },
                    navigation: {
                        nextEl: '.swiper-button-next',
                        prevEl: '.swiper-button-prev',
                    },
                    pagination: {
                        el: '.certify_pagination',
                        clickable :true,
                    },
                    on: {
                        progress: function(progress) {
                            for (var i = 0; i < this.slides.length; i++) {
                                var slide = this.slides.eq(i);
                                var slideProgress = this.slides[i].progress;
                                var  modify = 1;
                                if (Math.abs(slideProgress) > 1) {
                                    modify = (Math.abs(slideProgress) - 1) * 0.3 + 1;
                                }
                                var  translate = slideProgress * modify * 450 + 'px';
                                var   scale = 1 - Math.abs(slideProgress) /$scope.adsLength;
                                var  zIndex = 999 - Math.abs(Math.round(10 * slideProgress));
                                slide.transform('translateX(' + translate + ') scale(' + scale + ')');
                                slide.css('zIndex', zIndex);
                                slide.css('opacity', 1);
                                if (Math.abs(slideProgress) >1) {
                                    slide.css('opacity', 0);
                                }
                            }
                        },
                        setTransition: function(transition) {
                            for (var i = 0; i < this.slides.length; i++) {
                                var slide = this.slides.eq(i)
                                slide.transition(transition);
                            }

                        },
                        observer:true,//修改swiper自己或子元素时，自动初始化swiper
                        observeParents:true//修改swiper的父元素时，自动初始化swiper
                    }

                })
                certifySwiper.slideTo($scope.index);
            },300)
        }


    });